/**
 */
package opm.impl;

import java.util.Collection;

import opm.OPMLink;
import opm.OPMThing;
import opm.OpmPackage;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>OPM Thing</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link opm.impl.OPMThingImpl#getIncomingLinks <em>Incoming Links</em>}</li>
 *   <li>{@link opm.impl.OPMThingImpl#getOutcomingLinks <em>Outcoming Links</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class OPMThingImpl extends MinimalEObjectImpl.Container implements OPMThing {
	/**
	 * The cached value of the '{@link #getIncomingLinks() <em>Incoming Links</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIncomingLinks()
	 * @generated
	 * @ordered
	 */
	protected EList<OPMLink> incomingLinks;

	/**
	 * The cached value of the '{@link #getOutcomingLinks() <em>Outcoming Links</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOutcomingLinks()
	 * @generated
	 * @ordered
	 */
	protected EList<OPMLink> outcomingLinks;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected OPMThingImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OpmPackage.Literals.OPM_THING;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<OPMLink> getIncomingLinks() {
		if (incomingLinks == null) {
			incomingLinks = new EObjectContainmentEList<OPMLink>(OPMLink.class, this, OpmPackage.OPM_THING__INCOMING_LINKS);
		}
		return incomingLinks;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<OPMLink> getOutcomingLinks() {
		if (outcomingLinks == null) {
			outcomingLinks = new EObjectContainmentEList<OPMLink>(OPMLink.class, this, OpmPackage.OPM_THING__OUTCOMING_LINKS);
		}
		return outcomingLinks;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OpmPackage.OPM_THING__INCOMING_LINKS:
				return ((InternalEList<?>)getIncomingLinks()).basicRemove(otherEnd, msgs);
			case OpmPackage.OPM_THING__OUTCOMING_LINKS:
				return ((InternalEList<?>)getOutcomingLinks()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OpmPackage.OPM_THING__INCOMING_LINKS:
				return getIncomingLinks();
			case OpmPackage.OPM_THING__OUTCOMING_LINKS:
				return getOutcomingLinks();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OpmPackage.OPM_THING__INCOMING_LINKS:
				getIncomingLinks().clear();
				getIncomingLinks().addAll((Collection<? extends OPMLink>)newValue);
				return;
			case OpmPackage.OPM_THING__OUTCOMING_LINKS:
				getOutcomingLinks().clear();
				getOutcomingLinks().addAll((Collection<? extends OPMLink>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OpmPackage.OPM_THING__INCOMING_LINKS:
				getIncomingLinks().clear();
				return;
			case OpmPackage.OPM_THING__OUTCOMING_LINKS:
				getOutcomingLinks().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OpmPackage.OPM_THING__INCOMING_LINKS:
				return incomingLinks != null && !incomingLinks.isEmpty();
			case OpmPackage.OPM_THING__OUTCOMING_LINKS:
				return outcomingLinks != null && !outcomingLinks.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //OPMThingImpl
